{extend name='index@template/base'}{/extend}
{block name='style'}
<link rel="stylesheet" href="__STATIC__/plugins/bootstrap-treeview/bootstrap-treeview.min.css">
{/block}
{block name='script'}
<script src="__STATIC__/plugins/bootstrap-treeview/bootstrap-treeview.min.js"></script>
{/block}
{block name='content'}
<div class="wrapper">
    <form class="form-horizontal" id="form" action="{:url('ShopGoodsCategory/insert')}">
        <div class="box-body">
            <div class="form-group">
                <label class="col-sm-3 control-label"><i data-icomoon="&#xe05c"></i>对应商家</label>
                <div class="col-sm-6">
                    <select id="store" name='store_id' class="form-control select2" datatype="*" nullmsg="请选择对应商家">
                        {volist name="store['rows']" id="vo"}
                        <option value="{$vo.id}" {if $sid==$vo.id}selected{/if}>{$vo.text}</option>
                        {/volist}
                    </select>
                </div>
                <div class="col-sm-23"></div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">分类名称</label>
                <div class="col-sm-6">
                    <input class="form-control" type="text" name="name" datatype="*" nullmsg="请填写分类名称">
                </div>
                <div class="col-sm-3"></div>
            </div>
            <input type="hidden" name="icon">
            <!--<div class="form-group">-->
                <!--<label class="col-sm-3 control-label">分类图标</label>-->
                <!--<div class="col-sm-6">-->
                    <!--<input class="form-control" type="text" name="icon">-->
                <!--</div>-->
                <!--<div class="col-sm-3"></div>-->
            <!--</div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label">排序</label>
                <div class="col-sm-6">
                    <input class="form-control" type="number" name="sort" style="width: 139px;" value="0">
                </div>
                <div class="col-sm-3"></div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">是否使用</label>
                <div class="col-sm-6"  style="margin-top: 7px">
                    <span class="mr20" style="padding-right: 20px"><input type="radio" class="minimal" name="flag_use" value="1" checked> 启用</span>
                    <span class="mr20"><input type="radio" class="minimal" name="flag_use" value="0"> 禁用</span>
                </div>
                <div class="col-sm-3"></div>
            </div>
            <div class="form-group">
                <div class="col-sm-9 col-sm-offset-3">
                    <button type="submit" class="btn btn-primary">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                    <button type="button" class="btn btn-default radius ml-20" onclick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
                </div>
            </div>
        </div>
    </form>
</div>
{/block}
{block name='script_extra'}
<script>
    var tree_data_url="{:url('ShopGoodsCategory/cate_tree_data')}"
</script>
<script>
    $("#form").Validform({
        tiptype:2,
        showAllError:true,
        ajaxPost: true,
        callback: function (res) {
            if (res.success == true){
                layer.msg(res.message, {time: 1000},function () {
                    layer_close();
                    parent.location.reload();
                });
            }else{
                layer.alert(res.message);
            }
        }
    });
</script>
<script>
    function show_tree() {
        var treeview=$('.treeview');
        get_tree();
        if(treeview.is(":hidden")){
            treeview.show();
        }else{
            treeview.hide();
        }
    }
    function get_tree() {
        var treeview=$('.treeview');
        $.post(tree_data_url, function (json) {
            console.log(json);
            treeview.treeview({
                color:'#428bca',
                onNodeSelected: function(event, node) {
                    $('.tree-input').val(node.text);
                    $('#parent_id').val(node.id);
                    treeview.hide();
                },
                levels:1,
                data: json});
        });
    }
</script>
{/block}